home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / srtsltn / data1.cab / Target / Samples / VBSmpl / frmMain.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-08-05  |  11.5 KB  |  330 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
  4. Begin VB.Form frmMain 
  5.    BorderStyle     =   3  'Fixed Dialog
  6.    Caption         =   "Sort Solution Visual Basic Sample"
  7.    ClientHeight    =   5625
  8.    ClientLeft      =   45
  9.    ClientTop       =   300
  10.    ClientWidth     =   6870
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   221.894
  15.    ScaleMode       =   0  'User
  16.    ScaleWidth      =   100
  17.    ShowInTaskbar   =   0   'False
  18.    StartUpPosition =   2  'CenterScreen
  19.    Begin VB.CommandButton EditCommandFile 
  20.       Caption         =   "&Edit..."
  21.       Height          =   495
  22.       Left            =   3120
  23.       TabIndex        =   10
  24.       ToolTipText     =   "Edit the profile"
  25.       Top             =   1080
  26.       Width           =   1575
  27.    End
  28.    Begin ComctlLib.ProgressBar ProgressMerge 
  29.       Height          =   255
  30.       Left            =   240
  31.       TabIndex        =   8
  32.       Top             =   3000
  33.       Width           =   5895
  34.       _ExtentX        =   10398
  35.       _ExtentY        =   450
  36.       _Version        =   327682
  37.       Appearance      =   0
  38.    End
  39.    Begin ComctlLib.ProgressBar ProgressSort 
  40.       Height          =   255
  41.       Left            =   240
  42.       TabIndex        =   6
  43.       Top             =   2280
  44.       Width           =   5895
  45.       _ExtentX        =   10398
  46.       _ExtentY        =   450
  47.       _Version        =   327682
  48.       Appearance      =   0
  49.    End
  50.    Begin VB.CommandButton ManualSort 
  51.       Caption         =   "Test the &Manual Sort"
  52.       Height          =   615
  53.       Left            =   240
  54.       TabIndex        =   5
  55.       ToolTipText     =   "Execute a sort with SSICreateFromCommandString"
  56.       Top             =   4080
  57.       Width           =   3855
  58.    End
  59.    Begin MSComDlg.CommonDialog CommonDialog1 
  60.       Left            =   4800
  61.       Top             =   960
  62.       _ExtentX        =   847
  63.       _ExtentY        =   847
  64.       _Version        =   327681
  65.    End
  66.    Begin VB.CommandButton Browse 
  67.       Caption         =   "&Browse..."
  68.       Height          =   375
  69.       Left            =   4800
  70.       TabIndex        =   4
  71.       ToolTipText     =   "Browse for profiles"
  72.       Top             =   480
  73.       Width           =   1335
  74.    End
  75.    Begin VB.TextBox Filename 
  76.       Height          =   375
  77.       Left            =   240
  78.       TabIndex        =   2
  79.       ToolTipText     =   "Select a command file"
  80.       Top             =   480
  81.       Width           =   4455
  82.    End
  83.    Begin VB.CommandButton Run 
  84.       Caption         =   "&Execute"
  85.       Height          =   495
  86.       Left            =   240
  87.       TabIndex        =   1
  88.       ToolTipText     =   "Execute the sort"
  89.       Top             =   1080
  90.       Width           =   1815
  91.    End
  92.    Begin ComctlLib.StatusBar sbStatusBar 
  93.       Align           =   2  'Align Bottom
  94.       Height          =   270
  95.       Left            =   0
  96.       TabIndex        =   0
  97.       Top             =   5355
  98.       Width           =   6870
  99.       _ExtentX        =   12118
  100.       _ExtentY        =   476
  101.       SimpleText      =   ""
  102.       _Version        =   327682
  103.       BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
  104.          NumPanels       =   2
  105.          BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  106.             AutoSize        =   1
  107.             Object.Width           =   9499
  108.             Text            =   "Status"
  109.             TextSave        =   "Status"
  110.             Key             =   ""
  111.             Object.Tag             =   ""
  112.          EndProperty
  113.          BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  114.             Style           =   5
  115.             TextSave        =   "23:21"
  116.             Key             =   ""
  117.             Object.Tag             =   ""
  118.          EndProperty
  119.       EndProperty
  120.    End
  121.    Begin VB.Label VersionString 
  122.       Caption         =   "Version"
  123.       Height          =   255
  124.       Left            =   240
  125.       TabIndex        =   11
  126.       Top             =   4920
  127.       Width           =   5655
  128.    End
  129.    Begin VB.Label Label3 
  130.       Caption         =   "Merge Progress"
  131.       Height          =   255
  132.       Left            =   240
  133.       TabIndex        =   9
  134.       Top             =   2640
  135.       Width           =   2295
  136.    End
  137.    Begin VB.Label Label2 
  138.       Caption         =   "Sort Progress:"
  139.       Height          =   255
  140.       Left            =   240
  141.       TabIndex        =   7
  142.       Top             =   1920
  143.       Width           =   2295
  144.    End
  145.    Begin VB.Label Label1 
  146.       Caption         =   "&Profile:"
  147.       Height          =   255
  148.       Left            =   240
  149.       TabIndex        =   3
  150.       Top             =   120
  151.       Width           =   3855
  152.    End
  153. Attribute VB_Name = "frmMain"
  154. Attribute VB_GlobalNameSpace = False
  155. Attribute VB_Creatable = False
  156. Attribute VB_PredeclaredId = True
  157. Attribute VB_Exposed = False
  158. Option Explicit
  159. ' Look in the function Run_Click() to see how the
  160. ' Sort Solution library is integrated into this sample
  161. Private Sub Browse_Click()
  162.     CommonDialog1.CancelError = True
  163.     On Error GoTo ErrHandler
  164.     CommonDialog1.Filter = "Profiles (*.ssp)|*.ssp"
  165.     CommonDialog1.ShowOpen
  166.     Filename = CommonDialog1.Filename
  167.     Exit Sub
  168. ErrHandler:
  169.     Exit Sub
  170. End Sub
  171. ' Edit the current profile
  172. Private Sub EditCommandFile_Click()
  173.     Dim result As Double
  174.     result = Shell("notepad.exe " & Filename, vbNormalFocus)
  175. End Sub
  176. Private Sub Filename_Change()
  177.     If (Filename = "") Then
  178.         Run.Enabled = False
  179.         EditCommandFile.Enabled = False
  180.     Else
  181.         Run.Enabled = True
  182.         EditCommandFile.Enabled = True
  183.     End If
  184. End Sub
  185. ' A helper function for SSIGetVersion
  186. Private Function HIWORD(X As Long) As Integer
  187.    HIWORD = X \ &HFFFF&
  188. End Function
  189. ' A helper function for SSIGetVersion
  190. Private Function LOWORD(X As Long) As Integer
  191.    LOWORD = X And &HFFFF&
  192. End Function
  193. Private Sub Form_Load()
  194.     Dim result As Long
  195.     Dim lo As Long
  196.     Dim hi As Long
  197.     Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
  198.     Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
  199.     Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
  200.     Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
  201.     Run.Enabled = False
  202.     EditCommandFile.Enabled = False
  203.     ProgressSort.Min = 0
  204.     ProgressSort.Max = 100
  205.     ProgressMerge.Min = 0
  206.     ProgressMerge.Max = 100
  207.     ' Retrieve the version information from the DLL
  208.     result = SSIGetVersion(hi, lo)
  209.     VersionString = "Sort Solution Version: " & HIWORD(hi) & "." & LOWORD(hi) & ", Build " & HIWORD(lo)
  210. End Sub
  211. Private Sub Form_Unload(Cancel As Integer)
  212.     Dim i As Integer
  213.     'close all sub forms
  214.     For i = Forms.Count - 1 To 1 Step -1
  215.         Unload Forms(i)
  216.     Next
  217.     If Me.WindowState <> vbMinimized Then
  218.         SaveSetting App.Title, "Settings", "MainLeft", Me.Left
  219.         SaveSetting App.Title, "Settings", "MainTop", Me.Top
  220.         SaveSetting App.Title, "Settings", "MainWidth", Me.Width
  221.         SaveSetting App.Title, "Settings", "MainHeight", Me.Height
  222.     End If
  223. End Sub
  224. ' Display an Sort Solution error message for "SoSoCode"
  225. Private Sub ShowErrorMessage(SoSoCode As Long)
  226.     Dim result As Long
  227.     Dim msg As String
  228.     msg = String$(255, 0)
  229.     result = SSIGetErrorMessage(SoSoCode, msg, 255)
  230.     MsgBox msg, , "Sort Solution Error"
  231. End Sub
  232. Private Sub Label4_Click()
  233. End Sub
  234. ' This sub performs all steps required to use the Sort Solution engine
  235. ' in your application. Please read the comments for more information
  236. Private Sub Run_Click()
  237.     Dim handle As Long
  238.     Dim result As Long
  239.     Dim cmdstate As SORTSOL_CMDFILESTATUS
  240.     Dim stats As SORTSOL_STATS
  241.       
  242.     ' Set the Size member of both structures
  243.     cmdstate.Size = Len(cmdstate)
  244.     ' Wichtig: Dieses Element mu
  245.  mit False initialisiert
  246.     ' sein um unabsichtliches 
  247. berschreiben der Einstellungen
  248.     ' aus der Pofildatei zu vermeiden
  249.     cmdstate.Override = False
  250.     stats.Size = Len(stats)
  251.     ' Reset the progres bars
  252.     ProgressSort.Value = 0
  253.     ProgressMerge.Value = 0
  254.     Dim xlen As Long
  255.     xlen = Len(stats)
  256.     ' Create a sort instance from the profile "Filename"
  257.     result = SSICreateFromFile(handle, Filename, cmdstate)
  258.     If (result <> SOSOERR_SUCCESS) Then
  259.         ' If we have an error, get the corresponding message
  260.         ' from the library, display it and then return
  261.         ShowErrorMessage (result)
  262.         Exit Sub
  263.     End If
  264.     ' Change the mouse pointer to give some visual feedback
  265.     MousePointer = vbHourglass
  266.     result = SSIRegisterCallback(handle, AddressOf MySortCallback, 0)
  267.     ' And now execute the sort...
  268.     result = SSISort(handle)
  269.     If (result <> SOSOERR_SUCCESS) Then
  270.         ShowErrorMessage (result)
  271.         ' Don't forget to free the sort in this case
  272.         result = SSIFree(handle)
  273.         MousePointer = vbDefault
  274.         Exit Sub
  275.     End If
  276.         
  277.     ' Get some statistical information
  278.     result = SSIGetStats(handle, stats)
  279.     If (result <> SOSOERR_SUCCESS) Then
  280.         ShowErrorMessage (result)
  281.     End If
  282.     ' Free the sort instance
  283.     result = SSIFree(handle)
  284.     If (result <> SOSOERR_SUCCESS) Then
  285.         ShowErrorMessage (result)
  286.     End If
  287.     MousePointer = vbDefault
  288.     ' Display some statistical information
  289.     MsgBox "Sort completed in " & CLng((stats.SortTime + stats.MergeTime) / 1000) & " seconds." & _
  290.            Chr(13) & Chr(10) & Format(stats.BytesSortedLo, "##,##0") & " bytes processed." & _
  291.            Chr(13) & Chr(10) & Format(stats.RecordsProcessedLo, "##,##0") & " records processed." & _
  292.            Chr(13) & Chr(10) & Format(stats.RecordsFilteredLo, "##,##0") & " records filtered."
  293. End Sub
  294. ' This sub shows how to sort using a a command string
  295. Private Sub ManualSort_Click()
  296.     Dim command As String
  297.     Dim handle As Long
  298.     Dim cmdstate As SORTSOL_CMDFILESTATUS
  299.     Dim result As Long
  300.     ' Set the Size member of both structures
  301.     cmdstate.Size = Len(cmdstate)
  302.     ' Set the file names for input and output here
  303.     Const INPUT_FILE_NAME As String = "sort.dat"
  304.     Const OUTPUT_FILE_NAME As String = "sort.out"
  305.     ' Each line in the command string must contain a Carriage Return/Linefeed pair
  306.     ' at the end, hence the "Chr(13) & Chr(10)"
  307.     command = "InputFile(" & INPUT_FILE_NAME & ")" & Chr(13) & Chr(10) & _
  308.               "OutputFile(" & OUTPUT_FILE_NAME & ")" & Chr(13) & Chr(10) & _
  309.               "Drives(c:)" & Chr(13) & Chr(10) & _
  310.               "FileType(FIXED,20)" & Chr(13) & Chr(10) & _
  311.               "Key(Generic,ASC,0,0,20)"
  312.     ' Execute sort using the settings in "command"
  313.     result = SSICreateFromCommandString(handle, command, cmdstate)
  314.     If (result <> SOSOERR_SUCCESS) Then
  315.         ' If we have an error, get the corresponding message
  316.         ' from the library, display it and then return
  317.         ShowErrorMessage (result)
  318.         Exit Sub
  319.     End If
  320.     MousePointer = vbHourglass
  321.     result = SSISort(handle)
  322.     If (result <> SOSOERR_SUCCESS) Then
  323.         ShowErrorMessage (result)
  324.     Else
  325.         MsgBox "Sort completed"
  326.     End If
  327.     result = SSIFree(handle)
  328.     MousePointer = vbDefault
  329. End Sub
  330.